home *** CD-ROM | disk | FTP | other *** search
/ Java for 3D & VRML Worlds / Java for 3d and VRML Worlds.iso / doc / homepage / tutorials / lesson7 / shareeg1 / shareclick.java < prev    next >
Text File  |  1996-08-22  |  1KB  |  47 lines

  1. import vs.*;
  2. import vrml.*;
  3.  
  4. public class shareclick extends Script {
  5.    
  6.     SFNode sharedObjNode = (SFNode)getField("sharedobj");
  7.     Transform sharedObj = (Transform)sharedObjNode.getValue();
  8.  
  9.     public shareclick () {}
  10.  
  11.     public void touched (ConstSFBool flag, ConstSFTime time) {
  12.       
  13.       if(flag.getValue() == true)
  14.     return;
  15.  
  16.       if(Vscp.amIMaster()) {
  17.  
  18.          Vscp.sendApplSpecificMsgWithDist(sharedObjNode, "rpc_rotateBox", 
  19.                       "", Vscp.allClientsExceptMe);
  20.          actualChangeBox();
  21.       }
  22.       else {
  23.          Vscp.sendApplSpecificMsgWithDist(sharedObjNode, "rpc_touched", "",
  24.                        Vscp.responderOnly);
  25.       }
  26.     }
  27.  
  28.     public void rpc_touched(ConstSFString dum1, ConstSFTime dum2) {
  29.  
  30.        Vscp.sendApplSpecificMsgWithDist(sharedObjNode, "rpc_rotateBox",
  31.                       "", Vscp.allClientsExceptMe);
  32.        actualChangeBox();
  33.     } 
  34.  
  35.     public void rpc_rotateBox(ConstSFString data, ConstSFTime time) {
  36.     actualChangeBox();
  37.     }
  38.  
  39.     public void actualChangeBox() {
  40.        float [] axis = {0, 1, 0, 10};
  41.        float [] center = {0, 0, 0};
  42.  
  43.        sharedObj.rotateAroundLineDegree(axis, center, sharedObj.modeRelative);
  44.     }
  45. }
  46.                         
  47.